<!DOCTYPE html>
<html lang="en" style="height:100%">

<head>
	<meta charset="UTF-8">
	<meta name="viewport"
		content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
	<title>登录</title>
	<link rel="stylesheet" type="text/css" href="../../css/api.css" />
	<link rel="stylesheet" type="text/css" href="../../css/style.css" />
	<link rel="stylesheet" type="text/css" href="../../css/yzl.css" />
	<style>

	@keyframes rowup {
			0% {
					-webkit-transform: translate3d(0, 0, 0);
					transform: translate3d(0, 0, 0);
			}
			100% {
					-webkit-transform: translate3d(0, -2960px, 0);
					transform: translate3d(0, -2960px, 0);
			}
	}
	.rowup{
            -webkit-animation: 60s rowup linear infinite normal;
            animation: 60s rowup linear infinite normal;
            /*position: relative;*/
        }
	</style>
</head>

<body style="height:100%;overflow:hidden">
	<div class="login" id="app" style="height:100%;overflow:hidden">

		<div class="rowup" style="height:100%;">
		<img src="../../image/login_bg.jpg" width="100%" id="login_bg">
	</div>
	<div class="login_logo" >
		<img v-src="'../../image/login-logo.png'" width="90px">
	</div>
		<div class="login_middle">
			<div class="login_wx" v-myclick="login_wx">
				<img style="height: 12px" v-src="'../../image/login_wx.png'">
				<span>微信登录</span>
			</div>
			<div class="login_phone" v-myclick="login_phone">
				<span>手机号注册</span>
			</div>
		</div>
		<div class="login_bottom">
			<img v-src="'../../image/pulldown.png'" width="24px" v-myclick="closelogin">
		</div>

	</div>
<!-- <div class="modal-index-filter" style="top:0px; "   v-cloak> -->
</body>
<script src="../../script/api.js"></script>
<script src="../../script/vue.js"></script>
<script src="../../script/app.js"></script>
<script src="../../script/common.js"></script>
<script src="../../script/url.js"></script>
<script src="../../script/components.js"></script>
<script src="../../script/jquery.js"></script>

<script>
	var vm,
		wx,
		apiready = function () {
			setBSImg();
			new Vue({
				el: '#blank'
			})
			wx = api.require('wx');

			setBSImg();
			initApp();
			doubleBack();
			api.parseTapmode();
			addListeners();
		};

	function initApp() {
		var isBigImg = Vue.BSImg == 'big';
		vm = new Vue({
			el: '#app',
			data: {
				isClose: true,
				BSImg: {
					big: isBigImg,
					small: !isBigImg
				},
				appInstalled: {
					wx: true,
					qq: true,
				},
				active: false
			},
			computed: {
				imgNum: function () {
					if (this.appInstalled.wx && this.appInstalled.qq) {
						return 3;
					} else if (!this.appInstalled.wx && !this.appInstalled.qq) {
						return 1;
					} else {
						return 2
					}
				},
				imgOneWidth: function () {
					switch (this.imgNum) {
						case 2:
							return '50%';
						case 3:
							return '33.3%';
						case 4:
							return '25%';
					}
				},
			},
			methods: {
				closelogin:function(){
					api.openWin({
					    name: 'index',
					    url: '../../index.html',
							reload:true
					});
				},
				login_phone:function(){
					api.openWin({
					    name: 'register',
					    url: './register.html',
					});

				},
				login_init: function (user) {
					closeWin('index');
					setPrefs('user', user);
					setPrefs('token', user.token);
					setPrefs('username', user.nickname);
					setPrefs('portrait', user.memberAdd);
					setPrefs('member_id', user.memberId);
					// setRongtoken();
					api.sendEvent({
						name: 'reLogin'
					});
					api.openWin({
						reload: true,
						name: 'index',
						url: '../../index.html',
						hScrollBarEnabled: false,
						slidBackEnabled: false,
					});

				},
				bindAccount: function (data) {
					var params = {
						wxOpenId:data.openid,
						loginType:1
					};
					var callback = function (ret) {
						console.log(JSON.stringify(ret));
						if (ret.errcode==-1) {
							// openWin('../login/setInfo', data);
							setPrefs('openid',data.openid);
							openWin('../login/next', data);

						} else {
							setPrefs('openid',data.openid);
							vm.login_init(ret.content);

						}
					};
					pinet.post(APIURLP+'/play/login/userInfo', params, callback);
				},
				login_wx: function () {
					wx.auth({}, function (ret, err) {
						console.log(JSON.stringify(ret))
						if (!ret.status) {
						} else {
							wx.getToken({
								code: ret.code
							}, function (ret, err) {
								if (!ret.status) {
									// alert('获取授权 accessToken失败:' + err.code);
									api.toast({
										msg: '微信开小差了，请关闭app重新授权',
										duration: 3000,
										location: 'middle'
									});
									return false;
								} else {
									showProgress();
									wx.getUserInfo({
										accessToken: ret.accessToken,
										openId: ret.openId
									}, function (ret, err) {
										console.log(JSON.stringify(ret))
										if (!ret.status) {
											alert('获取用户信息失败:' + err.code);
											return false;
										} else {

											var data = ret;
											vm.bindAccount(data);
										}
									});
								}
							});
						}
					});
				},
				pwdlogin: function() {
					openWin('pwdLogin');
				}
			},
		})
	}

	function addListeners() {
	}

</script>

</html>
